/**
 *<p>Copyright: CHINA NATIONAL SOFTWARE & SERVICE CO.,LTD.</p>
 */
package com.cssnb.commons.utils;

/**
 * @Company: 中国软件与技术服务股份有限公司宁波子公司
 * @Project: 宁波市国税-外维系统
 * @Module ID: 
 * @Description: 
 * @JDK version used: JDK1.6
 * @Author: 卜繁晟
 * @Email: 5545795@qq.com | bufsh@css.com.cn
 * @Created Date: 2013-8-1 下午3:54:58
 */
//Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 2013-08-01 15:54:35
//Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
//Decompiler options: packimports(3) 
//Source File Name:   ResponseUtil.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;

public class ResponseUtil {

	public ResponseUtil(){}
	public static void sendJSONResponse(HttpServletResponse response, Object json) throws IOException{
		String jsonStr = "";
		try{
			jsonStr = JSON.toJSONString(json);
			logger.info(jsonStr);
		}catch(JSONException e){
			logger.error("json\u5E8F\u5217\u5316\u51FA\u73B0\u95EE\u9898", e);
		}
		response.setContentType("text/xml;charset=UTF-8");
		response.getWriter().write(jsonStr);
	}
	public static void sendJSONMessage(HttpServletResponse response, String type, String msg) throws IOException{
		Map map = new HashMap();
		map.put("type", type);
		map.put("msg", msg);
		sendJSONResponse(response, map);
	}

	private static final Log logger;
	static{
		logger = LogFactory.getLog(com.css.framework.common.util.ResponseUtil.class);
	}
}